﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Pibby.Core.Tests
{
	[TestClass]
	public class DurationTests
	{
		[TestMethod]
		public void EmptyDurationIsZeroMinutes()
		{
			Duration d = new Duration(string.Empty);

			//Assert.IsEmpty (d.Text);
			Assert.AreEqual (0, d.Value);
		}

		[TestMethod]
		public void InvalidDurationIsZeroMinutes()
		{
			Duration d = new Duration("ThisIsNotADuration");

            //Assert.AreEqual("--:--:--", d.Text);
            //Assert.AreEqual(d.ToString (), d.Text);
            //Assert.AreEqual(0, d.Value);
		}

		[TestMethod]
		public void SecondsOnlyDuration()
		{
			Duration d1 = new Duration("59");
			Duration d2 = new Duration("00:59");
			Duration d3 = new Duration("00:00:59");

			Assert.AreEqual(59, d1.Value);
			Assert.AreEqual(d1.Value, d2.Value);
			Assert.AreEqual(d1.Value, d3.Value);
		}

		[TestMethod]
		public void MinutesOnlyDuration()
		{
			Duration d1 = new Duration("1:00");
			Duration d2 = new Duration("0:01:00");
			Duration d3 = new Duration("00:01:00");

			Assert.AreEqual(60, d1.Value);
			Assert.AreEqual(d1.Value, d2.Value);
			Assert.AreEqual(d1.Value, d3.Value);
		}

		[TestMethod]
		public void MinutesAndSecondsDuration()
		{
			Duration d1 = new Duration("1:25");
			Duration d2 = new Duration("0:01:25");
			Duration d3 = new Duration("00:01:25");

			Assert.AreEqual(85, d1.Value);
			Assert.AreEqual(d1.Value, d2.Value);
			Assert.AreEqual(d1.Value, d3.Value);
		}

		[TestMethod]
		public void HoursAndMinutesAndSecondsDuration()
		{
			Duration d1 = new Duration("1:23:45");
			Duration d2 = new Duration("01:23:45");

			Assert.AreEqual(5025, d1.Value);
			Assert.AreEqual(d1.Value, d2.Value);
		}

	}
}
